package com.sawyer.controller;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.management.ValueExp;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author huanm
 * <p>
 * thymeleaf所有操作都需要通过controller实现跳转
 */
@Controller
public class IndexController {
    @GetMapping(value = "/index")
    public String toIndex(Model m, HttpSession s, HttpServletRequest request) {
        SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyy-MM-dd");
       // m.addAttribute("time",sDateFormat.format(new Date()));
  //    request.getSession().setAttribute("time",sDateFormat.format(new Date()));
         s.setAttribute("time",sDateFormat.format(new Date()));
        return "ems/login";
    }

    @GetMapping(value = "/toRegister")
    public String toRegister() {
        return "ems/regist";
    }

    @GetMapping(value = "toSave")
    public String toSave() {
        return "ems/addEmp";
    }

}
